package com.mind.adjust.service.impl;

import com.mind.customer.mapper.AjObjectMapper;
import com.mind.system.domain.AjObject;
import com.mind.adjust.service.AjObjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 对象(AjObject)表服务实现类
 *
 * @author makejava
 * @since 2024-07-11 17:40:13
 */
@Service("objectService")
public class AjObjectServiceImpl implements AjObjectService {
    @Autowired
    private AjObjectMapper objectMapper;

    /**
     * 查询对象信息集合
     * 
     * @param object 对象信息
     * @return 对象信息集合
     */
    @Override
    public List<AjObject> selectObjectList(AjObject object)
    {
        return objectMapper.selectObjectList(object);
    }

    /**
     * 通过对象ID查询对象信息
     * 
     * @param objectId 对象ID
     * @return 角色对象信息
     */
    @Override
    public AjObject selectObjectById(Long objectId)
    {
        return objectMapper.selectObjectById(objectId);
    }

    /**
     * 删除对象信息
     * 
     * @param objectId 对象ID
     * @return 结果
     */
    @Override
    public int deleteObjectById(Long objectId)
    {
        return objectMapper.deleteObjectById(objectId);
    }

    /**
     * 批量删除对象信息
     * 
     * @param objectIds 需要删除的对象ID
     * @return 结果
     */
    @Override
    public int deleteObjectByIds(Long[] objectIds)
    {
        return objectMapper.deleteObjectByIds(objectIds);
    }

    /**
     * 新增保存对象信息
     * 
     * @param object 对象信息
     * @return 结果
     */
    @Override
    public int insertObject(AjObject object)
    {
        return objectMapper.insertObject(object);
    }

    /**
     * 修改保存对象信息
     * 
     * @param object 对象信息
     * @return 结果
     */
    @Override
    public int updateObject(AjObject object)
    {
        return objectMapper.updateObject(object);
    }
    
    /**
     * 批量插入
     *
     * @param objectList 附件类型信息
     * @return 结果
     */
    @Override
    public int batchInsert(List<AjObject> objectList) {
        int size = 0;
        for(AjObject object: objectList) {
            if (objectMapper.selectObjectByName2(object.getName()) == null){
                objectMapper.insertObject(object);
                size ++;
            }
        }
        return size;
    }
}
